<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">
<style>
.gradeA{
	cursor:pointer!important;
}
</style>																																											
<body>																																														
	<div id="content">																																										
		<div id="content-header"></div>																																						
		<div class="container-fluid">																																							
			<div class="widget-box">																																							
				<div class="widget-title">																																					
					<h5>列表</h5>																																									
			    </div>																																											
				<div class="widget-content nopadding">																																		
					<table id="${lowerClassName}Table" url="<%=path%>/${lowerClassName}/getList" class="table table-bordered data-table ">																	
						<thead>																																									
							<tr role="row">																																					
							<#list columns as col>
								<th class="ui-state-default" role="columnheader"  style="" name="${col.fieldName}"<#list uniqueIndex.fieldNames as unique><#if unique=col.fieldName> primaryKey="true" </#if></#list>>${col.columnComments}</th> 										
							</#list>
								<th class="ui-state-default" role="columnheader"  style="" name="work-box">操作</th>
							</tr>																																								
						</thead>																																								
						<tbody role="alert" aria-live="polite" aria-relevant="all">																										
						</tbody>																																								
					</table>
					<div  class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix">
						<div style="float:left;">
							<span style="width:65px;height:26px;margin:2px 0  0 4px;">每页</span>
								<select style="width:65px;height:26px;margin:2px 0  0 4px;" onchange="toPage(1,this.value)">
									<option value="10">10</option>
									<option value="15">15</option>
									<option value="20">20</option>
									<option value="50">50</option>
									<option value="100">100</option>
								</select>
							<span style="width:65px;height:26px;margin:2px 0  0 4px;">条</span>
						</div>
						<div id="_paging" style="float:right;margin:2px 5px 2px 4px;" class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers">
						</div>
					</div>																																										
				</div>																																											
			</div>																																												
		</div>																																													
	</div>	
	
			<div id="modelDialog" class="modal hide fade in" style="display:none;">
		<div class="modal-header">
			<a class="close" data-dismiss="modal">x</a>
			<h4>操作提示</h4>
		</div>
		<div class="modal-body">
			<h4>确认删除该项记录吗？</h4>
		</div>
		<div class="modal-body">
			<button id="confirm" type="button" class="btn btn-success">确认</button>
			<button  type="button class="btn btn-default" data-dismiss="modal">关闭</button>
		</div>
	</div>																																														
</body>																																														
     <script type="text/javascript">																																						
    	    var param = mainParam.param ; //接收传参																																		
    	    //加载数据																																												
    	    toPage();																																											
    	    //分页函数																																												
    	    function toPage(pageNum,pageSize){																																							
    	    	if(pageNum == 0){																																								
    	    		return ;																																									
    	    	}																																												
    	    	param.pageNum = pageNum?pageNum:1;	
    	    	param.pageSize = pageSize?pageSize:"";
    	    	C.load(${r'$'}("${r'#'}${lowerClassName}Table"),param);																																				
    	    }																																													
  
      	    //详细																																											
     		function detail(_this){																																							
					var $form = _this.siblings("form");
					$form.attr("action","<%=path%>/${lowerClassName}/detail?pageNum="+param.pageNum);																												
					toLoad($form.attr("action"),$form.serialize());	    																																						
     		}
     		 
     	    //编辑																																											
     		function edit(_this){																																							
					var $form = _this.siblings("form");
					$form.attr("action","<%=path%>/${lowerClassName}/form?pageNum="+param.pageNum);																												
					toLoad($form.attr("action"),$form.serialize());    																																						
     		}   																																											
     		//删除																																											
     		function del(_this){																																							
	 			$("#modelDialog").modal();
				$("#confirm").click(function(){																																				
	         		var form = _this.siblings("form");																																		
	     			var _tr = _this.parent().parent();																																			
	     			var sib = _tr.siblings("tr").length;	
	         		${r'$'}.ajax({																																								
	         				url:"<%=path %>/${lowerClassName}/del",																																		
	         				data:form.serialize(),																																				
	         				type:"post",																																						
	         				success:function(text){																																				
	         					if(text.success){																																				
	         						C.gritter("删除成功！");																																			
	         						if(sib==0){																																					
	             						//删除完成刷新当前页（删除的数据为当前页唯一条时，pageNum-1）																											
	             						_tr.remove();  //如果删除的记录为当前结果集的唯一一条，前后台同时做删除操作																									
	             						toPage((param.pageNum-1)>0?param.pageNum-1:1);																											
	             					}else{																																						
	             						//删除完成刷新当前页																																			
	             						toPage(param.pageNum);																																	
	             					}																																							
	         					}else{
	         						C.gritter("删除失败！");																																							
	         					}																																								
	         				}																																									
	         			});																																										
	     		})	
	     	} 																																												
     </script>																																												
</html>	    																																												

